package com.cg.design.graphicdesignpattern.facade.pagemaker;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * 从邮件中获取用户名的类，可获取指定数据库名所对应的properties的实例
 *
 * @program: LeetCode->Database
 * @description: 从邮件中获取用户名的类，可获取指定数据库名所对应的properties的实例
 * @author: cg
 * @create: 2022-03-27 15:33
 **/
class Database {

    /**
     * 防止外部new出Database的实例
     */
    private Database() {

    }

    public static Properties getProperties(String dbname) {
        String filename = dbname + ".txt";
        Properties properties = new Properties();
        try {
            properties.load(new FileInputStream(filename));
        } catch (IOException e) {
            System.out.println("Warning: " + filename + " is not found.");
        }
        return properties;
    }

}
